package net.zjitc.service.Impl;

import net.zjitc.dao.CategoryDao;
import net.zjitc.dao.CategorySecondDao;
import net.zjitc.dao.Impl.CategoryDaoImpl;
import net.zjitc.dao.Impl.CategorySecondDaoImpl;
import net.zjitc.pojo.Category;
import net.zjitc.pojo.CategorySecond;
import net.zjitc.service.CategoryService;

import java.util.List;

/**
 * Created by dell on 2017/11/18.
 */
public class CategoryServiceImpl implements CategoryService {
    CategoryDao dao=new CategoryDaoImpl();
    CategorySecondDao csdao=new CategorySecondDaoImpl();
    public List<Category> findAllCategory() {
        List<Category>list=dao.findAllCategory();
        for(Category c:list) {
            List<CategorySecond> cslist=csdao.findByCid(c.cid);
            c.setCategorySecondList(cslist);
        }
        return list;
    }

    public void categoryAdd(Category category) {
        dao.categoryAdd(category);
    }

    public Category findCategoryById(String cid) {
        return dao.findCategoryById(cid);
    }

    public void categoryEdit(Category category) {
        dao.categoryEdit(category);
    }

    public void CategoryDelete(String cid) {
        dao.CategoryDelete(cid);
    }
}
